#ifndef _SOCKET_CONNECTION_H_
#define _SOCKET_CONNECTION_H_

#include <string>
#include <sstream>

#ifdef _WIN32

#include <winsock2.h>
#include <ws2tcpip.h>

#pragma comment (lib, "Ws2_32.lib")
#pragma comment (lib, "Mswsock.lib")
#pragma comment (lib, "AdvApi32.lib")

#elif

#include <sys/socket.h>
#include <netinet/in.h>
#include <sys/types.h>
#include <unistd.h>
#include <netdb.h>

#endif

class Connection
{
public:
	enum SOCKET_STATUS
	{
		OPEN,
		CLOSED,
		SENDING,
		RECEIVING
	};

	Connection(std::string address, std::string port);
	~Connection();

	bool open();
	void close();
	bool isOpen();

	SOCKET getSocket();
	
	void send(std::string message);
	void send(std::string message, int flags);
	int	receive(int length, char *buffer);
	int	receive(int length, char *buffer, int flags);

protected:
	SOCKET conn;
	SOCKET_STATUS status;
	std::string address;
	std::string port;
};

#endif